package cn.gok.until;

import java.util.Iterator;
import java.util.Map;

/**
 * @Author: zhengyx
 * @Date: 2022/7/11 10:52
 * @Version 1.0
 */
public class HashMap {
    public static void main(String[] args) {
        Demo();
    }

    private static void Demo() {
        Map<Integer,String> map=new java.util.HashMap<>();
        System.out.println(map.put(1,"aaa"));
        System.out.println(map.put(2,"sdf"));
        System.out.println(map.put(3,"jgth"));

        for (Integer key : map.keySet()) {
            String value = map.get(key);
            System.out.println(key+"   "+value);
        }

        Iterator<Integer> it =map.keySet().iterator();
        while (it.hasNext()){
            Integer key =it.next();
            String value=map.get(key);
            System.out.println(key+"   "+value);
        }

        for (Map.Entry<Integer,String> e:map.entrySet()){
            Integer key =e.getKey();
            String value = e.getValue();
            System.out.println(key+"   "+value);
        }

        Iterator<Map.Entry<Integer,String>> it2=map.entrySet().iterator();
        while (it2.hasNext()){
            Map.Entry<Integer,String> e=it2.next();
            System.out.println(e.getKey()+"-------"+e.getValue());
        }


        System.out.println(map.size());
        System.out.println(map);

        System.out.println(map.remove(2));
        System.out.println(map);
    }
}
